home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9762 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: nova.umuc.edu!not-for-mail
  2. From: srussell@nova.umuc.edu (Steve Russell)
  3. Newsgroups: comp.lang.c++
  4. Subject: More Class
  5. Date: 4 Mar 1996 00:47:56 -0500
  6. Organization: University of Maryland University College
  7. Message-ID: <4he06c$qhp@nova.umuc.edu>
  8.  
  9.     I'm doing my first c++ program on unix, my first c++ programs
  10.     with classes, and my first c++ program linking all the seperate
  11.     components ( main program, class header, member function file)
  12.     together.
  13.  
  14.     I would like to ask some preventative questions before I compile
  15.     as I did  most of this without text support:
  16.  
  17.  
  18.     The first is if you use the function "strcmp" do you have to 
  19.     actually rename your strings 's1' and 's2' and can you put
  20.         just any two strings in the function call?
  21.  
  22.     Also, using emacs, c++, g++, do I compile the class, the member
  23.     function file, and the main program seperatley or will emacs
  24.     do it all at once if compile the main function?
  25.  
  26.     Also, this is my first time doing classes, doing them in seperate
  27.     files, and linking them.  I'm also doing it without any examples.
  28.     I wrote down the preamble to each three components below.  Could
  29.     you see if I suffixed the files appropiatley for unix & c++?
  30.     Also could you see if I "#included" everything I should to make
  31.     sure it all links okay?  Also, I dont really know what the purpose
  32.     of "endif" is, did I use enough of them?
  33.  
  34.     Thanks I owe you a big one
  35.  
  36.     Steve
  37.     srussell@nova.umuc.edu
  38.  
  39.  
  40.  
  41. 1. class header file name( contains decalrations and member prototypes):
  42.     EmpRecords.h
  43.     
  44.     //FILE: EmpRecords.h
  45.     // STORES AND MANIPULATES FILES OF EMPLOYEE RECORDS
  46.  
  47.     #ifndef EMPLOYEERECORDS_H_
  48.     #define EMPLOYEERECORDS_H_
  49.  
  50.         #include <EmpRecords.cc>
  51.     #include <fstream.h>
  52.     #include <iomanip.h>
  53.     #include <iostream.h>
  54.     #include <stdlib.h>
  55.  
  56.     ( the class, declarations and prototypes )
  57.  
  58.     #endif
  59.     
  60.  
  61. 2. file for the class member functions: EmpRecords.cc:
  62.    
  63.     //FILE: EmpRecords.cc
  64.     //MEMBER FUNCTIONS FOR CLASS EMPLOYEE_RECORDS.H
  65.  
  66.     #ifndef EMPLOYEERECORDS_CC_
  67.     #define EMPLOYEERECORDS_CC_
  68.  
  69.     #include <EmpRecords.h>
  70.     #include <fstream.h>
  71.     #include <iomanip.h>
  72.     #include <iostream.h>
  73.     #include <stdlib.h>
  74.  
  75.     ( member function definitions )
  76.  
  77.     #endif
  78.  
  79. 3. main program that uses class employee_records: project2
  80.    
  81.     // FILE: 240_2.C
  82.     // MAINIPULATES EMPLOYEE RECORDS VIA A CLASS
  83.  
  84.  
  85.     #include <EmpRecords.h>
  86.     #include <fstream.h>
  87.     #include <iomanip.h>
  88.     #include <iostream.h>
  89.     #include <stdlib.h>
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.